<?php


$num=5;

function fact($num){
  if($num==1)
  return 1;

  return $num*fact($num-1);
}

echo fact($num);
